package com.example.demo.controller;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * 普通controller
 * Created by Administrator on 2017/11/9.
 */
@Controller
public class IndexController {

    @RequestMapping("/")
    public String index() {
        return "index";
    }



    @RequestMapping("/test")
    public String test(HttpServletRequest request) {
        List<String> books = new ArrayList<>();
        books.add("红楼梦");
        books.add("三国演义");
        books.add("水浒传");
        books.add("西游记");

        request.setAttribute("books", books);
        request.setAttribute("key", "所得税");
        return "hello";
    }

    @RequestMapping("/testJsp")
    public String testJsp(Model model) {
        List<String> books = new ArrayList<>();
        books.add("红楼梦");
        books.add("三国演义");
        books.add("水浒传");
        books.add("西游记");

        model.addAttribute("books", books);
        model.addAttribute("key", "所得税");
        return "test";
    }
}
